import React, { useState } from 'react'
import { useEffect } from 'react'

export default function App() {
  let [opacity,setOpacity]= useState(1)

  useEffect (()=>{
    //设置定时器
    const In = setInterval(() => {
      opacity -= 0.1
      if (opacity <= 0) {
        opacity = 1
      }
      setOpacity(opacity)
    },100)

    //清除定时器
    return ()=>{
      clearInterval(In)
    }
  }, [])



  return (
    <div><h1 style={{opacity}}>海贼王</h1></div>
  )
}
